package logic.ships.moveableShip;

import com.jme.bounding.BoundingVolume;
import com.jme.math.Vector3f;
import com.jme.scene.TriMesh;

import logic.slots.NodeSlot;
import logic.trails.ShipTrail;

public class NozzleSlot extends NodeSlot {
	
	private static final long serialVersionUID = 1L;
		
	private TriMesh inner, outer;
	private Vector3f innerLoc, outerLoc;
	private float maxWidth;
	private ShipTrail trail;
	private MovableShip ship;
	
	public NozzleSlot(TriMesh inner, TriMesh outer, MovableShip ship) {
		super("NozzleSlot", ship, inner, outer);
		this.inner = inner;
		this.outer = outer;
		this.ship = ship;
	}
	
	@Override
	public void checkSlots() {
		innerLoc = getLocalPos(inner);
		outerLoc = getLocalPos(outer);
		
		BoundingVolume innerVolume = inner.getWorldBound();
		
		maxWidth = getMaxSizeOf(innerVolume) * 2f;
		
		float width = maxWidth * 1.7f;
		trail = new ShipTrail(width, ship, this);
		
		ship.addTrail(trail);
		
		inner.removeFromParent();
		outer.removeFromParent();
		removeFromParent();
	}
	
	public Vector3f getInnerLocation() { return innerLoc; }
	
	public Vector3f getOuterLocation() { return outerLoc; }
}